//标签选择发送数据
var carQueryData = {
    "startRow": 1, //第几页开始
    "brandOrCarLevel": "", //搜索
    "brand": "", //品牌
    "defaultSort": "", //排序
    "ndownPaymentStart": "", //首付
    "ndownPaymentEnd": "",
    "nmonthlyPaymentStart": "", //月供
    "nmonthlyPaymentEnd": "",
    "priceStart": "", //车价Start
    "priceEnd": "",
    "downPaymentRatio": "", //首付比例 发送给后台时拼接在此后 10%首付-0%首付
    "downPaymentRatioList": {
        "zeropayments": "", //0首付
        "fivepayments": "", //5%首付
    },
    "newCarShelf": "", //新车上架
    "carRaisingWorryFree": "", //养车无忧
    "monthlySupplyDrop": "", //月供直降
    "newEnergy": "", //新能源
    "carLevel": "", //车型  carLevel=SUV-中型车-紧凑型车，你用-拼接成字符串过来
    //以下字段不传  拼接在priceStart后面
    "carLevelList": {
        "minCar": "", //微小型车
        "smallCar": "", //紧凑型
        "middleCar": "", //中型车
        "middleLargeCar": "", //中大型车
        "suvCar": "", //SUV
        "mpvCar": "", //MPV
        "runCar": "", //跑车
    }

};
//标签选择页面渲染数据
var carRenderData = {
    "startRow": 1, //第几页开始
    "brand": "", //品牌
    "brandOrCarLevel": "", //搜索
    "defaultSort": "", //排序
    "ndownPayment": "", //首付
    "nmonthlyPayment": "", //月供
    "price": "", //车价Start
    "zeropayments": "", //0首付
    "fivepayments": "", //5%首付
    "newCarShelf": "", //新车上架
    "carRaisingWorryFree": "", //养车无忧
    "monthlySupplyDrop": "", //月供直降
    "newEnergy": "", //新能源
    "minCar": "", //微小型车
    "smallCar": "", //紧凑型
    "middleCar": "", //中型车
    "middleLargeCar": "", //中大型车
    "suvCar": "", //SUV
    "mpvCar": "", //MPV
    "runCar": "", //跑车
};
// carQueryData carRenderData 两个是为了操作页面处理逻辑的   可跟据实际情况使用
// ——————————————————————————————————————————————————————————————————————————
// 第二个滑块代码
var arr = {"star":['', '不限'],"price":[0,1000]};
$('.monthlyInstallment').on('click', function() {
    navSelectChangeThisCss(this, ".selecteList_month", [".selecteList_downPayment", ".selecteList"], [".downPayment", ".defaultSort"]);
});
// $('.nmonthlyPayment_ul li:last').click();
$('.nmonthlyPayment_ul li').on('click', function() {
    console.log('asdsadsa');
    $(this).addClass("selected");
    $(this).siblings().removeClass("selected");
    setTimeout(function() {}, 100);
    var val = $(this).data("val");
    var txt = $(this).find('p').text();

    arr.star = [val, txt];
});
var hotelData = $api.getStorage('TOUCH_START_PRICE_BAR');
var from = 0;
var to = 1000;
if (hotelData) {
    hotelData = JSON.parse(hotelData);

    arr.star = [hotelData.star[0], hotelData.star[1]];

    from = parseInt(hotelData.price[0]);
    to = parseInt(hotelData.price[1]);
    moveSliderRange2(from, to);
}
//月供滑动
$(".range_2").ionRangeSlider({
    min: 0, //最小值
    max: 1000, //最大值
    from: from, //默认从哪个值开始选
    to: to, //默认选到哪个值
    type: 'double', //设置类型
    step: 1,
    prefix: "", //设置数值前缀
    postfix: "元", //设置数值后缀
    prettify: true,
    hasGrid: true,
    onChange: function(data) { //数据变化时触发
        moveSliderRange2(data.from, data.to);
    },
});
function moveSliderRange2(leftNum, rightNum) {
    if (leftNum >= 0 && rightNum < 1000) {
        $('.bxyc').text(leftNum + '-' + rightNum + '元').attr("data-leftNum", leftNum).attr("data-rightNum", rightNum)

    } else if (leftNum === 1000 && rightNum === 1000) {

        $('.bxyc').text('1000+').attr("data-leftNum", 1000).attr("data-rightNum", "1000");

    } else if (leftNum > 0 && leftNum < 1000 && rightNum === 1000) {

        $('.bxyc').text(leftNum + '元以上').attr("data-leftNum", leftNum).attr("data-rightNum", "20000");

    } else if (leftNum === 0 && rightNum > 999) {

        $('.bxyc').text("1000+").attr("data-leftNum", "0").attr("data-rightNum", "1000");

    }
}

$('.confirmButton2').on('click', function() {
    var min = parseInt($('.bxyc').attr("data-leftNum"));
    var max = parseInt($('.bxyc').attr("data-rightNum"));

    console.log(min);
    console.log(max);
    if (min === 0 && max === 1000) {
        min = max = 0;
    }

    arr.price = [min, max];
    api.sendEvent({
        name: 'starPriceEv',
        extra: {
            data: arr,
        }
    });
    $('.selectClass').animate({bottom: -310},200);

    if (max === 0) {
        max = 1000;
    }
    if(max > 1000){
        max = 1000;
    }
    arr.price = [min, max];

    $api.setStorage('TOUCH_START_PRICE_BAR', JSON.stringify(arr));

    api.sendEvent({
        name: 'cancelCheckEv'
    });

    setTimeout(function () {
        api.closeFrame({
            name: 'star_price_frm'
        });
    },200)
});
